<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="author" content="wangbo">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <h1></h1>
  <script>
    //1、获取元素
    const h1 = document.querySelector('h1') //获取到要显示计时的标签
    setInterval(() => {
      let date = new Date();
      let nian = date.getFullYear()
      // console.log(nian);
      // 0-11   1月份是0 12 月份是11
      let yue = date.getMonth() + 1
      // console.log(yue);
      // 每月的多少天
      let ri = date.getDate()
      // console.log(ri);
      // 0-23
      let shi = date.getHours()
      // console.log(shi);
      // 0-59
      let fen = date.getMinutes()
      // console.log(fen);
      // 0-59
      let miao = date.getSeconds()
      // console.log(miao);
      // console.log(nian+"年"+yue+"月"+ri+"日"+shi+'时'+fen+'分'+miao+'秒');
      h1.innerHTML =  nian + "年" + yue + "月" + ri + "日" + shi + '时' + fen + '分' + miao + '秒'
    }, 1000);
  </script>
</body>

</html>